// 1.引入公用样式表
require("../../assets/css/index.less");
// require("../../assets/fonts/iconfont.css")

// 2.引入当前样式表
require("./courseIntro.less");

// 引入插件

// 3.引入公用js模块
let validator = require("../../utils/validator.js");
let https = require("../../utils/https.js");

// 4.引入工具函数
let dom = require("../../utils/dom.js");

// 引入weui
const weui = require("../../assets/lib/weui/weui.min.js");
require("../../assets/lib/weui/weui.min.css");

// 判断是否有登录
dom.isToken();
dom.ready(function () {
	// 回到圈子页面
	dom.goTo("#video >span", "training");
	// dom.goTo("#startBtn", "starTraining");

	// 根据课程id获取课程信息

	https.get(`/api/train/courseDetail${location.search}`, function (res) {
		let courseId = location.search.split("=")[1];
		// 解构
		let { name, calorie, time, desc, frequency, instrument, fragments } =
			res.data;
		dom.$("#name").textContent = name;
		dom.$("#calorie").textContent = calorie;
		dom.$("#time").textContent = time;
		dom.$("#desc").textContent = desc;
		dom.$("#frequency").textContent = frequency;
		dom.$("#instrument").textContent = instrument;
		dom.$("#fragment").src = https.BASE_URL + fragments[courseId].videoUrl;
	});
	dom.$("#startBtn").addEventListener("click", function () {
		location.href = `starTraining.html${location.search}`;
	});
	dom.goTo("#back", "social");
});
